package com.qf.admin.timer;


import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.io.File;

@Component
public class ClearTempFiles {

    @Value("${fileTempDir}")
    private String fileTempDir;

    private Logger logger = Logger.getLogger(ClearTempFiles.class);

    public void clearFile(){

        logger.info("清除临时文件");

        File file = new File(fileTempDir);

        if (file.isDirectory()){

            //获得目录下所有的文件
            File[] files = file.listFiles();

            if (null != files && files.length>0){

                for (File file1 : files) {

                    file1.delete();
                }
            }
        }

    }
}
